package firstDay;

import java.util.Arrays;

/**
 * @author nhp
 * @version 1.0
 * @description 分发饼干
 * @date 2024-05-24 22:08
 */
public class LeetCode455 {

    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int result = 0;
        int index = 0;
        int flag = 0;
        for(int i = 0 ;i < g.length;i++){
            for(;index < s.length;index++){
                if(s[index] >= g[i]){
                    flag = 1;
                    index++;
                    break;
                }
            }
            if(flag == 1){
                result++;
                flag = 0;
            }
        }
        return result;
    }
}
